package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.McnInstitutions;
import com.ruoyi.system.service.IMcnInstitutionsService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * MCN信息Controller
 * 
 * @author shawu
 * @date 2024-08-15
 */
@RestController
@RequestMapping("/system/institutions")
public class McnInstitutionsController extends BaseController
{
    @Autowired
    private IMcnInstitutionsService mcnInstitutionsService;

    /**
     * 查询MCN信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:institutions:list')")
    @GetMapping("/list")
    public TableDataInfo list(McnInstitutions mcnInstitutions)
    {
        startPage();
        List<McnInstitutions> list = mcnInstitutionsService.selectMcnInstitutionsList(mcnInstitutions);
        return getDataTable(list);
    }

    /**
     * 导出MCN信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:institutions:export')")
    @Log(title = "MCN信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, McnInstitutions mcnInstitutions)
    {
        List<McnInstitutions> list = mcnInstitutionsService.selectMcnInstitutionsList(mcnInstitutions);
        ExcelUtil<McnInstitutions> util = new ExcelUtil<McnInstitutions>(McnInstitutions.class);
        util.exportExcel(response, list, "MCN信息数据");
    }

    /**
     * 获取MCN信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:institutions:query')")
    @GetMapping(value = "/{mcnId}")
    public AjaxResult getInfo(@PathVariable("mcnId") Long mcnId)
    {
        return success(mcnInstitutionsService.selectMcnInstitutionsByMcnId(mcnId));
    }

    /**
     * 新增MCN信息
     */
    @PreAuthorize("@ss.hasPermi('system:institutions:add')")
    @Log(title = "MCN信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody McnInstitutions mcnInstitutions)
    {
        return toAjax(mcnInstitutionsService.insertMcnInstitutions(mcnInstitutions));
    }

    /**
     * 修改MCN信息
     */
    @PreAuthorize("@ss.hasPermi('system:institutions:edit')")
    @Log(title = "MCN信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody McnInstitutions mcnInstitutions)
    {
        return toAjax(mcnInstitutionsService.updateMcnInstitutions(mcnInstitutions));
    }

    /**
     * 删除MCN信息
     */
    @PreAuthorize("@ss.hasPermi('system:institutions:remove')")
    @Log(title = "MCN信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{mcnIds}")
    public AjaxResult remove(@PathVariable Long[] mcnIds)
    {
        return toAjax(mcnInstitutionsService.deleteMcnInstitutionsByMcnIds(mcnIds));
    }
}
